characters = 'a5bLc!S0BdV,H1Ne*fAKg6h i3R9$Uj^PkW@?E7l.mIYM2n8G(oTQDp%XqrC)#s&Jtu4vFwOxZyz'
#characters = 'abcdefghijklmnopqrstuvwxyz'
key = 'jdof'
	
class PolyCipher():
	#input the number of mappings the polycipher is to use
	def __init__(self):
		self.key = key
			
	#input plaintext and get a cipher
	def encrypt(self,message):
		ret = []
		for i in range(0,len(message)):
			current = message[i]#get current char
			#if current.isalpha():
			position = characters.find(current)#find position of char in character list
			position-= characters.find(self.key[i%(len(self.key))])#decrease position based on current character in the key
			position%=len(characters)#shouldnt go past length of characters
			ret.append(characters[position])#add ciphercharacter to return string
			#else:
			#	ret.append(current)
		return ''.join(ret)
	#input ciphered text and get plaintext
	def decrypt(self,message):
		ret = []
		for i in range(0,len(message)):
			current = message[i]#get current char
			#if current.isalpha():
			position = characters.find(current)#find position of char in character list
			position+= characters.find(self.key[i%(len(self.key))])#increase position based on current character in the key
			position%=len(characters)#shouldnt go past length of characters
			ret.append(characters[position])#add ciphercharacter to return string
			#else:
			#	ret.append(current)
		return ''.join(ret)